<?php

require_once __DIR__ . '/../bean/CRE.php';
require_once __DIR__ . '/abstract/AbstractDAO.php';

/**
 * Description of CREDAO
 *
 * @author hyzandey
 */
class CREDAO extends AbstractDAO {

    const QUERY_REGULAR = 'select * from cre_regular order by cre';
    const QUERY_EJA = 'select * from cre_eja order by cre';

    private $isEja;

    public function __construct($isEja) {
        parent::__construct();
        $this->isEja = $isEja;
    }

    public function find() {
        $this->query = $this->isEja ? self::QUERY_EJA : self::QUERY_REGULAR;

        $this->executaQuery();

        $creList = array();

        while ($row = $this->proximaLinhaResultado()) {
            $creList[] = new CRE($row['cre']);
        }

        return $creList;
    }

}

?>
